import VueRouter from 'vue-router'

// 将push和replace都重写
const arr = ['push', 'replace']
arr.forEach(item => {
  const storage = VueRouter.prototype[item]
  VueRouter.prototype[item] = function (path, successCb, errorCb) {
    if (successCb || errorCb) {
      storage.call(this, path, successCb, errorCb)
    } else {
      storage.call(this, path).catch(() => { })
    }
  }
})
